package com.spa.infrastructure.mapper;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.admin.DouYinCommentDTO;
import com.spa.domain.entity.DouYinComment;
import com.spa.infrastructure.enums.dict.order.OrderStatusEnum;
import com.spa.infrastructure.repository.po.DouYinCommentPO;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

@Mapper
@MapperConfig(unmappedTargetPolicy = ReportingPolicy.WARN)
public interface DouYinCommentMapperStruct {

    DouYinCommentMapperStruct INSTANCE = Mappers.getMapper(DouYinCommentMapperStruct.class);


    DouYinComment po2Entity(DouYinCommentPO po);

    Page<DouYinComment> po2Entity4Page(Page<DouYinCommentPO> page);

    PageResult<DouYinCommentDTO> entity2Dto4Page(Page<DouYinComment> page);

    @Mapping(source = "createTime", target = "createTime", qualifiedByName = "int2Str")
    DouYinCommentDTO entity2Dto(DouYinComment douYinComment);

    @Named("int2Str")
    default String int2Str(int createTime) {
        return DateUtil.date(createTime* 1000L).toString("yyyy-MM-dd HH:mm:ss");
    }
}
